using System; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Collections; 

namespace LibreriaWC
{
    /// <summary>
    /// Clase que extiende al control Table 
    /// y es utilizado por el Web User Control Errors para mostrar mensajes de error.
    /// </summary>
    [ToolboxData("<{0}:tblErrors runat=server></{0}:tblErrors>")] 
    public class tblErrors : System.Web.UI.WebControls.Table 
    { 
        private ArrayList _rows; 

        public tblErrors() 
        { 
            _rows = new ArrayList(); 
        } 

        /// <summary>
        /// Agregar mensaje.
        /// </summary>
        /// <param name="message">Mensaje.</param>
        public void Add(string message) 
        { 
            _rows.Add(message); 
        } 

		/// <summary>
		/// Indica si hay errores
		/// </summary>
		public bool HasErrors
		{
			get { return _rows.Count > 0; }
		}

        protected override void Render(System.Web.UI.HtmlTextWriter output) 
        { 
            base.Render(output); 
        } 

        protected override void OnPreRender(System.EventArgs e) 
        { 
            TableRow row; 

            foreach (object item in _rows) 
            { 
                row = new TableRow(); 
                row.Cells.Add(new TableCell()); 
                row.Cells[0].Text = item.ToString(); 
                base.Rows.Add(row); 
            } 

            base.OnPreRender(e); 
        } 
    }
}